import os
import sys
import PBVC_Golang_Adapter.asty.nodes as asty_nodes

sys.path.append(os.path.dirname(os.path.dirname(__file__)))
ASSETS_PATH = os.path.join(os.path.dirname(__file__), "assets")

pj = os.path.join


def asset_path(p: str) -> str:
    return pj(ASSETS_PATH, p)


def load_ast(filename: str, args=None) -> asty_nodes.FileNode:
    c_file = os.path.join(ASSETS_PATH, filename)
    with open(c_file, encoding="utf-8") as f:
        tree: asty_nodes.FileNode = asty_nodes.FileNode.parse_raw(f.read())
        return tree
